# Contributor: Olivier Mauras <olivier@mauras.ch>
# Maintainer:
_pkgname=pdns-recursor # upstream package name
pkgname="$_pkgname"
pkgver=4.3.3
pkgrel=0
pkgdesc="PowerDNS Recursive Server"
url="https://www.powerdns.com/"
arch="all !s390x !mips !mips64" # broken context
license="GPL-2.0-only"
depends="dns-root-hints"
makedepends="autoconf automake libtool boost-dev openssl-dev libsodium-dev lua5.3-dev
	net-snmp-dev protobuf-dev"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
pkgusers="recursor"
pkggroups="recursor"
source="https://downloads.powerdns.com/releases/$_pkgname-$pkgver.tar.bz2
	https://github.com/tsuna/boost.m4/raw/3d67ee84e9149f6279a8df2113f5a86f0a83bd0d/build-aux/boost.m4
	$pkgname-GPGKEYS::https://www.powerdns.com/powerdns-keyblock.asc
	$_pkgname.initd
	recursor.conf
	"
# secfixes:
#   4.3.2-r0:
#     - CVE-2020-14196
#   4.3.1-r0:
#     - CVE-2020-10995
#     - CVE-2020-12244
#   4.1.9-r0:
#     - CVE-2019-3806
#     - CVE-2019-3807
#   4.1.8-r0:
#     - CVE-2018-16855
#   4.1.7-r0:
#     - CVE-2018-10851
#     - CVE-2018-14644
#     - CVE-2018-14626
#   4.1.1-r0:
#     - CVE-2018-1000003
#   4.0.7-r0:
#     - CVE-2017-15090
#     - CVE-2017-15092
#     - CVE-2017-15093
#     - CVE-2017-15094

# Work-around for boost version 1.72 until next 4.3.x release
prepare() {
	default_prepare
	mv "$srcdir"/boost.m4 "$builddir"/m4/boost.m4
	autoreconf -i
}

build() {
	./configure --prefix=/usr \
		--sysconfdir=/etc/pdns \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--libdir=/usr/lib/pdns \
		--enable-unit-tests
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	rm -v "$pkgdir"/etc/pdns/recursor.conf-dist

	install -m755 -D "$srcdir/$_pkgname.initd" \
		"$pkgdir/etc/init.d/$pkgname"

	install -v -m640 -o root -g recursor \
		-D "$srcdir/recursor.conf" \
		"$pkgdir/etc/pdns/recursor.conf"

	ln -s ../../usr/share/dns-root-hints/named.root \
		"$pkgdir/etc/pdns/root.hints"
}

_gpg_signature_extensions="sig"
_gpgfingerprints="
	FBAE 0323 821C 7706 A5CA 151B  DCF5 13FA 7EED 19F3
	1628 90D0 689D D12D D33E 4696  1C5E E990 D2E7 1575
	good:B76C D467 1C09 68BA A87D  E61C 5E50 715B F2FF E1A7
	good:16E1 2866 B773 8C73 976A  5743 6FFC 3343 9B0D 04DF
	"

sha512sums="285f12d3cb2edaca7507dd9dad1356b60076d43af678458346489562ea8933a01d61d2430d5282b6afd213839ee684ad83e5f523c9a272f382d74ccc238bd9d5  pdns-recursor-4.3.3.tar.bz2
490e1afd940bfd3ffe0c3e32d778eaf08ef5c92cb46fc09b527b7b2bac6fc2aba1afbcc0e8e88481809330d701679126b1c1ed81d2770bc605d3b000e177c561  boost.m4
7027c12c450ecdf4fa569e882eebdb437f166c71090f867928fddb08c558df452922ee3b33fa1dad3097b322bdb79a2096e07d9d2e9f15423464a64df6a9cde3  pdns-recursor-GPGKEYS
71f7be51d3a9a78f22f3946e95534d4f5b37b3bcbd1891ad3a17095be545fdb0eaf239d58c9f40ccc642542150c0b35ed025bf69acabfa779c0ab10c67a5e796  pdns-recursor.initd
466852d5e865630a3443ce96b6b3122f39d1a508fa8e3d884956925d04b1208724a3ca436920a765f106f5cb76ce3d8f5481ff16b9e02cf2e6b7c44f8c811e03  recursor.conf"
